package com.xxp.service.impl;

import com.xxp.entity.Fuzhou;
import com.xxp.mapper.FuzhouMapper;
import com.xxp.service.FuzhouService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class FuzhouServiceImpl implements FuzhouService {
    @Autowired
    private FuzhouMapper fuzhouMapper;


    @Override
    public Fuzhou select(Integer id) {
        Fuzhou fz = fuzhouMapper.select(id);
        return fz;
    }

    public void update(Fuzhou fuzhou){
        Integer views = fuzhou.getViews();
        views++;
        fuzhou.setViews(views);
      fuzhouMapper.update(fuzhou);//浏览数自动递增
    }

    @Override
    public void updateAll(Fuzhou fuzhou) {
        fuzhou.setUpdatetime(new Date());
        fuzhouMapper.updateAll(fuzhou);
    }

    @Override
    public List<Fuzhou> selectAll() {
        return fuzhouMapper.selectAll();
    }


}
